1. Field of the Present Invention
The present invention relates generally to computer graphics and more particularly to a circuit that efficiently determines a floating point exponentiation.
2. History of Related Art
Graphics display subsystems are almost universally employed in microprocessor based computer systems to facilitate a variety of graphics tasks and applications including computer-assisted drafting, architectural design, simulation trainers for aircraft and other vehicles, molecular modeling, virtual reality applications, and video games. Graphics processors, graphics adapters, and a variety of similarly designed computer products provide specialized hardware to speed the execution of graphics instructions and rendering of graphic images. These processors and adapters typically include, for example, circuitry optimized for translating, rotating, and scaling 3D graphic images.
In a typical application, a graphical image that is displayed on a display terminal or other output device is composed of one or more graphic primitives. For purposes of this disclosure, a graphic primitive may be thought of as one or more points, lines, or polygons that are associated with one another, such as by being connected to one another. Typically, the displayed image is generated by creating one or more graphic primitives, assigning various attributes to the graphic primitives, defining a viewing point and a viewing volume, determining which of the graphic primitives are within the defined viewing volume, and rendering those graphic primitives as they would appear from the viewing point. This process can require a tremendous amount of computing power to keep pace with the ever increasingly complex graphics applications that are commercially available. Accordingly, designers of graphics systems and graphics applications are continuously seeking cost effective means for improving the efficiency at which graphic images are rendered and displayed.
Typically a software application program generates a 3D graphics scene, and provides the scene, along with lighting attributes, to an application programming interface (API) such as the OpenGL(copyright) API developed by Silicon Graphics, Inc. Complete documentation of OpenGL(copyright) is available in M. Woo et al., OpenGL Programming Guide: The Official Guide to Learning OpenGL, Version 1.2 (Addison Wesley Longman, Inc. 1999) and D. Schreiner, OpenGL Reference Manual, Third Edition: The Official Reference Document to OpenGL, Version 1.2 (Addison Wesley Longman, Inc. 1999), both of which are incorporated by reference herein.
A 3D graphics scene typically includes of a number of polygons that are delimited by sets of vertices. The vertices are combined to form larger primitives, such as triangles or other polygons. The triangles (or polygons) are combined to form surfaces, and the surfaces are combined to form objects. Each vertex is associated with a set of attributes. Vertex attributes may include a position, including three Cartesian coordinates x, y, and z, a material color, which describes the color of the object to which the vertex belongs, and a normal vector, which describes the direction to which the surface is facing at the vertex. Each vertex may also be associated with texture coordinates and/or an alpha (transparency) value. In addition, the scene itself may be associated with a set of attributes including, as examples, an ambient color that typically describes the amount of ambient light and one or more individual light sources. Each light source has a number of properties associated with it, including a direction, an ambient color, a diffuse color, and a specular color.
Rendering is employed within the graphics system to create two-dimensional image projections of a 3D graphics scene for display on a monitor or other display device. Typically, rendering includes processing geometric primitives (e.g., points, lines, and polygons) by performing one or more of the following operations as needed: transformation, clipping, culling, lighting, fog calculation, and texture coordinate generation. Rendering further includes processing the primitives to determine component pixel values for the display device, a process often referred to specifically as rasterization.
The OpenGL(copyright) API specification and other API""s such as the graPHIGS API define the allowed vertex and scene attributes and the equations used to determine attribute values. These equations typically include extensive use of floating point values and floating point calculations. Determining lighting attributes, for example, requires a sequence of floating point calculations including floating point exponentiation calculations of the form Y=BE in which the base B and exponent E are both floating point values. A floating point exponentiation calculation is notoriously slow (i.e., expensive) in a graphics adapters that relies primarily on software to perform the calculation. It is therefore desirable to implement a floating point exponentiation circuit that determines a floating point value quickly.
The problem identified above is achieved with a floating point exponentiation circuit suitable for calculating the value BE as disclosed herein where B and E are floating point values. The floating point exponentiation circuit includes circuitry for producing a value P, where P is approximately equal to E*((BEXPxe2x88x92127)+log2(1.BMAN)), BEXP is the exponent field of the base B, and 1.BMAN is the 24-bit mantissa field of the base B. The floating point exponentiation circuit further includes circuitry for adjusting the value P such that the mantissa field of the floating point representation of the adjusted value of P includes a portion Pi (the integer portion) that indicates the integer portion of P and a portion Pf (the fractional portion) that indicates the fractional portion of P. The floating point exponentiation circuit further includes circuitry for extracting Pi from the floating point representation of the adjusted value of P and producing an exponent field for the floating point value BE and circuitry for extracting Pf from the floating point representation of the adjusted value of P and producing a mantissa field for the floating point value BE. The circuitry for producing P may include a first lookup table configured to retrieve a floating point representation of (BEXPxe2x88x92127) and a logarithm unit configured to generate an estimate of the log2(1.BMAN). The logarithm unit may include a slope lookup table and a Y intercept table that together define a linear approximation to the curve y=log2(x) at a point x defined by a portion of BMAN. The floating point exponentiation circuit may further include floating point comparator circuitry configured to compare the value P against upper and lower limits. The circuit may be configured to output an upper limit value if the value P exceeds the upper limit and a lower limit value if the value P exceeds the lower limit value. The floating point format of the adjusted value of P may have a common exponent field regardless of the value of P if P is greater than the lower limit and less than the upper limit. The circuitry for adjusting the value P may include a floating point adder configured to add a floating point constant to the value P. In one embodiment, the circuitry for extracting Pi from the adjusted value of P includes a fixed point adder that adds a value of 127 to Pi and stores the resulting sum into the exponent field portion of a floating point result register. The circuitry for extracting Pf from P may include an exponential unit that estimates the value 2{circumflex over ( )}Pf. The exponential unit may include an estimation lookup table that returns a value of 2{circumflex over ( )}N where N represents a first portion of Pf. The exponential circuit may further include a correction lookup table that returns a correction factor based on the value of N. The correction factor may be multiplied by the value Pf to produce a correction factor that is added to the value retrieved from the estimation lookup table in a fixed point adder. The output of the fixed point adder is then stored in the mantissa portion of the result register.